#ifndef MAP_H
#define MAP_H

#include "Cell.h"
#include "Player.h"
#include "SDL.h"
#include "Entity.h"
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>

class Map {
public:
	Map(std::string infoFilename, std::string mapFilename, SDL_Surface* tileSheet);
	int getMapWidth() { return mapWidth; }
	int getMapHeight() { return mapHeight; }
	int getCellWidth() { return cellWidth; }
	int getCellHeight() { return cellHeight; }
	SDL_Surface* getTileSheet() { return tileSheet; }
	Cell* getCell(int x, int y) { return mapGrid[y][x]; }
	std::vector<Entity*> getEntityList() { return entities; }
	bool isGood() { return good; }
	Renderable::Direction checkMapCollision(Renderable* entity);

private:
	SDL_Surface* tileSheet;
	int mapWidth;
	int mapHeight;
	int cellWidth;
	int cellHeight;
	bool good;
	std::vector<std::vector<Cell*> > mapGrid;
	std::vector<Cell> cells;
	std::vector<Entity*> entities;

	void initMap(std::string infoFilename, std::string mapFilename, SDL_Surface* tileSheet);
	std::vector<std::string> tokenize(std::string str, char dilim);
	Renderable::Direction collisionCheck(SDL_Rect a, SDL_Rect b);
};

#endif